//
//  CAAddBankView.m
//  LNH
//
//  Created by twentylx on 2018/2/8.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAAddBankView.h"

@implementation CAAddBankView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}


/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.titleView];
    [self.titleView addSubview:self.titleLabel];
    [self addSubview:self.bankView];
    [self.bankView addSubview:self.nameLabel];
    [self.bankView addSubview:self.nameTextField];
    [self.bankView addSubview:self.lineView];
    [self.bankView addSubview:self.cardNoLabel];
    [self.bankView addSubview:self.cardNoTextField];
    [self.bankView addSubview:self.line1View];
    [self.bankView addSubview:self.nextButton];
}

- (void)updateConstraints {
    [super updateConstraints];
    
    [_titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self);
        make.height.mas_equalTo(40);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleView).offset(20);
        make.top.equalTo(self.titleView).offset(10);
        make.height.mas_equalTo(20);
    }];
    
    [_bankView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.titleView.mas_bottom).offset(10);
        make.height.mas_equalTo(400);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.centerY.equalTo(self.nameTextField);
        make.width.mas_equalTo(100);
    }];
    
    [_nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right);
        make.top.equalTo(self.bankView).offset(10);
        make.right.equalTo(self.bankView);
        make.height.mas_equalTo(44);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self.bankView);
        make.bottom.equalTo(self.nameTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_cardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.centerY.equalTo(self.cardNoTextField);
        make.width.mas_equalTo(100);
    }];
    
    [_cardNoTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cardNoLabel.mas_right);
        make.top.equalTo(self.lineView.mas_bottom).offset(10);
        make.right.equalTo(self.bankView);
        make.height.mas_equalTo(44);
    }];
    
    [_line1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self.bankView);
        make.bottom.equalTo(self.cardNoTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bankView).offset(40);
        make.top.equalTo(self.line1View.mas_bottom).offset(40);
        make.right.equalTo(self.bankView).offset(-40);
        make.height.mas_equalTo(44);
    }];
}

#pragma mark get & set
- (UIView *)titleView {
    if (!_titleView) {
        _titleView = [UIView new];
        _titleView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _titleView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"请绑定持卡人本人的银行卡";
        _titleLabel.textColor = RGBCOLOR(158, 158, 158);
        _titleLabel.font = [UIFont systemFontOfSize:14];
    }
    return _titleLabel;
}

- (UIView *)bankView {
    if (!_bankView) {
        _bankView = [UIView new];
        _bankView.backgroundColor = [UIColor whiteColor];
    }
    return _bankView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.text = @"持卡人";
        _nameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _nameLabel;
}

- (UITextField *)nameTextField {
    if (!_nameTextField) {
        _nameTextField = [UITextField new];
        _nameTextField.placeholder = @"请输入持卡人姓名";
        _nameTextField.font = [UIFont systemFontOfSize:16];
    }
    return _nameTextField;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _lineView;
}

- (UILabel *)cardNoLabel {
    if (!_cardNoLabel) {
        _cardNoLabel = [UILabel new];
        _cardNoLabel.text = @"卡号";
        _cardNoLabel.font = [UIFont systemFontOfSize:16];
    }
    return _cardNoLabel;
}

- (UITextField *)cardNoTextField {
    if (!_cardNoTextField) {
        _cardNoTextField = [UITextField new];
        _cardNoTextField.placeholder = @"请输入银行卡号";
        _cardNoTextField.font = [UIFont systemFontOfSize:16];
    }
    return _cardNoTextField;
}

- (UIView *)line1View {
    if (!_line1View) {
        _line1View = [UIView new];
        _line1View.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _line1View;
}

- (UIButton *)nextButton {
    if (!_nextButton) {
        _nextButton = [UIButton new];
        [_nextButton setTitle:@"下一步" forState:UIControlStateNormal];
        [_nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _nextButton.titleLabel.font = [UIFont systemFontOfSize:24];
        _nextButton.backgroundColor = RGBCOLOR(233, 85, 19);
        _nextButton.layer.cornerRadius = 5;
    }
    return _nextButton;
}

@end
